<script type="text/javascript">
	var runScript = {
		callback: function (note, mess){
			if(note.type=="success"){
				var syn =note.syn.split('|');
				$.each(syn, function(i, src){
					if(syn.length == (i+1)){
						$.getScript(src, function(){
							if($.cookie('Gadfly_auth')){
								$('#AjaxLogin').find('div.panel-body:eq(0)').addClass('hidden');
								$('#AjaxLogin').find('div.panel-body:eq(1)').removeClass('hidden');
								$.getJSON("{U('Index/getAuthcode')}", function(auth){
									$('#AjaxLogin').find('li:eq(0)>strong').text(auth.uid);
									$('#AjaxLogin').find('li:eq(1)>strong').text(auth.username);
									$('#AjaxLogin').find('li:eq(2)>strong').text(auth.realname);
								});
							}else{
								$('#AjaxLogin').find('div.panel-body:eq(0)').removeClass('hidden');
								$('#AjaxLogin').find('div.panel-body:eq(1)').addClass('hidden');
							}
						});
					}else{
						$.getScript(src);
					}
				});
				mess.update({
					message: note.msg,
					type: note.type,
					showCloseButton: true,
					hideAfter: 5
				});
			}
		}
	};
</script>
<div class="panel panel-default">
	<div class="panel-heading"><strong>UCenter 同步登录窗口</strong><em>（AJAX登录方式）</em></div>
	<div class="panel-body {if isset($auth)}hidden{/if}">
		<form class="form-horizontal" role="form" action="{U('Index/login')}" method="ajax" data-sea="Validator"  data-config="runScript">
			<div class="form-group">
				<label for="inputEmail1" class="col-sm-2 control-label">用户名</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" id="inputEmail1" placeholder="用户名" name="username">
				</div>
			</div>
			<div class="form-group">
				<label for="inputPassword2" class="col-sm-2 control-label">密码</label>
				<div class="col-sm-10">
					<input type="password" class="form-control" id="inputPassword2" placeholder="Password" name="password">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-1 col-sm-5">
					<button type="submit" class="btn btn-primary btn-block">登录</button>
				</div>
				<div class="col-sm-offset-1 col-sm-5">
					<button type="reset" class="btn btn-info btn-block">取消</button>
				</div>
			</div>
		</form>
	</div>
	<div class="panel-body {if !isset($auth)}hidden{/if}">
		<div class="row">
			<div class="col-sm-offset-2 col-sm-10">
				<h3><strong><em>Ajax退出</em>方式用户登录成功</strong></h3>
				<ul>
					<li>用户UID： <strong>{$auth.uid}</strong></li>
					<li>用户名： <strong>{$auth.username}</strong></li>
					<li>真实姓名： <strong>{$auth.realname}</strong></li>
				</ul>
			</div>
			<div class="col-sm-offset-2 col-sm-10">
				<a href="{U('Index/logout')}" class="btn btn-info btn-block" data-sea="Confirm" data-config="runScript" onclick="return false;"><em>Ajax</em>方式退出登录状态</a>
			</div>
		</div>
	</div>
</div>